#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QLabel* label = new QLabel(this);
    label->setText("Hello qt!!!");
    label->move(320,250);
   QFont font;
   font.setFamily("黑体");
   font.setPixelSize(40);
   font.setBold(true);
   font.setUnderline(true);
   font.setStrikeOut(true);
   label->setFont(font);

   QPushButton* button_yes = new QPushButton(this);
   button_yes->setToolTip("this is a yes button");
   connect(button_yes,&QPushButton::clicked,this,&Widget::handleYesButton);
   button_yes->move(500,0);
   button_yes->setText("YES");
   button_yes->setToolTipDuration(3000);

   QPushButton* button_no = new QPushButton(this);
   button_no->setToolTip("this is a no button");
   connect(button_no,&QPushButton::clicked,this,&Widget::handleNoButton);
   move(0,0);
   button_no->setText("NO");
   button_no->setToolTipDuration(3000);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::handleYesButton()
{
    if(windowTitle() == "YES!!!")
        qDebug("already finish!!!");
    else
        setWindowTitle("YES!!!");
}
void Widget::handleNoButton()
{
    if(windowTitle() == "NO!!!")
        qDebug("already finish!!!");
    else
        setWindowTitle("NO!!!");
}

